package edu.siu.math.egut.util;
 
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
 

 /**
     * A class to store some data associated to exceptional groups.
     */

 class ExceptionalGroupData {
   
    private final static int[][] E6roots = { { 1, 0, 0, 0, 0, 0 },/*@\label{roots}@*/
	{ 0, 1, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0 },
	{ 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 1 }, { 1, 0, 1, 0, 0, 0 },
	{ 0, 1, 0, 1, 0, 0 }, { 0, 0, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 0 },
	{ 0, 0, 0, 0, 1, 1 }, { 1, 0, 1, 1, 0, 0 }, { 0, 1, 1, 1, 0, 0 },
	{ 0, 1, 0, 1, 1, 0 }, { 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 1, 1, 1 },
	{ 1, 1, 1, 1, 0, 0 }, { 1, 0, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 },
	{ 0, 1, 0, 1, 1, 1 }, { 0, 0, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 0 },
	{ 1, 0, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 2, 1, 0 },
	{ 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 2, 1, 0 }, { 0, 1, 1, 2, 1, 1 },
	{ 1, 1, 1, 2, 1, 1 }, { 1, 1, 2, 2, 1, 0 }, { 0, 1, 1, 2, 2, 1 },
	{ 1, 1, 2, 2, 1, 1 }, { 1, 1, 1, 2, 2, 1 }, { 1, 1, 2, 2, 2, 1 },
	{ 1, 1, 2, 3, 2, 1 }, { 1, 2, 2, 3, 2, 1 } };
    private final static int[][] E7roots = { { 1, 0, 0, 0, 0, 0, 0 },
	{ 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 },
	{ 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 1, 0, 0 },
	{ 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 1 },
	{ 1, 0, 1, 0, 0, 0, 0 }, { 0, 1, 0, 1, 0, 0, 0 },
	{ 0, 0, 1, 1, 0, 0, 0 }, { 0, 0, 0, 1, 1, 0, 0 },
	{ 0, 0, 0, 0, 1, 1, 0 }, { 0, 0, 0, 0, 0, 1, 1 },
	{ 1, 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0, 0 },
	{ 0, 1, 0, 1, 1, 0, 0 }, { 0, 0, 1, 1, 1, 0, 0 },
	{ 0, 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 0, 1, 1, 1 },
	{ 1, 1, 1, 1, 0, 0, 0 }, { 1, 0, 1, 1, 1, 0, 0 },
	{ 0, 1, 1, 1, 1, 0, 0 }, { 0, 1, 0, 1, 1, 1, 0 },
	{ 0, 0, 1, 1, 1, 1, 0 }, { 0, 0, 0, 1, 1, 1, 1 },
	{ 1, 1, 1, 1, 1, 0, 0 }, { 1, 0, 1, 1, 1, 1, 0 },
	{ 0, 1, 1, 2, 1, 0, 0 }, { 0, 1, 1, 1, 1, 1, 0 },
	{ 0, 1, 0, 1, 1, 1, 1 }, { 0, 0, 1, 1, 1, 1, 1 },
	{ 1, 1, 1, 2, 1, 0, 0 }, { 1, 1, 1, 1, 1, 1, 0 },
	{ 1, 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 2, 1, 1, 0 },
	{ 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 2, 2, 1, 0, 0 },
	{ 1, 1, 1, 2, 1, 1, 0 }, { 1, 1, 1, 1, 1, 1, 1 },
	{ 0, 1, 1, 2, 2, 1, 0 }, { 0, 1, 1, 2, 1, 1, 1 },
	{ 1, 1, 2, 2, 1, 1, 0 }, { 1, 1, 1, 2, 2, 1, 0 },
	{ 1, 1, 1, 2, 1, 1, 1 }, { 0, 1, 1, 2, 2, 1, 1 },
	{ 1, 1, 2, 2, 2, 1, 0 }, { 1, 1, 2, 2, 1, 1, 1 },
	{ 1, 1, 1, 2, 2, 1, 1 }, { 0, 1, 1, 2, 2, 2, 1 },
	{ 1, 1, 2, 3, 2, 1, 0 }, { 1, 1, 2, 2, 2, 1, 1 },
	{ 1, 1, 1, 2, 2, 2, 1 }, { 1, 2, 2, 3, 2, 1, 0 },
	{ 1, 1, 2, 3, 2, 1, 1 }, { 1, 1, 2, 2, 2, 2, 1 },
	{ 1, 2, 2, 3, 2, 1, 1 }, { 1, 1, 2, 3, 2, 2, 1 },
	{ 1, 2, 2, 3, 2, 2, 1 }, { 1, 1, 2, 3, 3, 2, 1 },
	{ 1, 2, 2, 3, 3, 2, 1 }, { 1, 2, 2, 4, 3, 2, 1 },
	{ 1, 2, 3, 4, 3, 2, 1 }, { 2, 2, 3, 4, 3, 2, 1 } };
    private final static int[][] E8roots = {
	{ 1, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0, 0, 0 },
	{ 0, 0, 1, 0, 0, 0, 0, 0 }, { 0, 0, 0, 1, 0, 0, 0, 0 },
        { 0, 0, 0, 0, 1, 0, 0, 0 }, { 0, 0, 0, 0, 0, 1, 0, 0 },
        { 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 1 },
        { 1, 0, 1, 0, 0, 0, 0, 0 }, { 0, 1, 0, 1, 0, 0, 0, 0 },
        { 0, 0, 1, 1, 0, 0, 0, 0 }, { 0, 0, 0, 1, 1, 0, 0, 0 },
        { 0, 0, 0, 0, 1, 1, 0, 0 }, { 0, 0, 0, 0, 0, 1, 1, 0 },
        { 0, 0, 0, 0, 0, 0, 1, 1 }, { 1, 0, 1, 1, 0, 0, 0, 0 },
        { 0, 1, 1, 1, 0, 0, 0, 0 }, { 0, 1, 0, 1, 1, 0, 0, 0 },
        { 0, 0, 1, 1, 1, 0, 0, 0 }, { 0, 0, 0, 1, 1, 1, 0, 0 },
        { 0, 0, 0, 0, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, 1, 1, 1 },
        { 1, 1, 1, 1, 0, 0, 0, 0 }, { 1, 0, 1, 1, 1, 0, 0, 0 },
        { 0, 1, 1, 1, 1, 0, 0, 0 }, { 0, 1, 0, 1, 1, 1, 0, 0 },
        { 0, 0, 1, 1, 1, 1, 0, 0 }, { 0, 0, 0, 1, 1, 1, 1, 0 },
        { 0, 0, 0, 0, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 0, 0, 0 },
        { 1, 0, 1, 1, 1, 1, 0, 0 }, { 0, 1, 1, 2, 1, 0, 0, 0 },
        { 0, 1, 1, 1, 1, 1, 0, 0 }, { 0, 1, 0, 1, 1, 1, 1, 0 },
        { 0, 0, 1, 1, 1, 1, 1, 0 }, { 0, 0, 0, 1, 1, 1, 1, 1 },
        { 1, 1, 1, 2, 1, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 0, 0 },
        { 1, 0, 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 2, 1, 1, 0, 0 },
        { 0, 1, 1, 1, 1, 1, 1, 0 }, { 0, 1, 0, 1, 1, 1, 1, 1 },
        { 0, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 2, 2, 1, 0, 0, 0 },
        { 1, 1, 1, 2, 1, 1, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 0 },
        { 1, 0, 1, 1, 1, 1, 1, 1 }, { 0, 1, 1, 2, 2, 1, 0, 0 },
        { 0, 1, 1, 2, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1 },
        { 1, 1, 2, 2, 1, 1, 0, 0 }, { 1, 1, 1, 2, 2, 1, 0, 0 },
        { 1, 1, 1, 2, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1 },
        { 0, 1, 1, 2, 2, 1, 1, 0 }, { 0, 1, 1, 2, 1, 1, 1, 1 },
        { 1, 1, 2, 2, 2, 1, 0, 0 }, { 1, 1, 2, 2, 1, 1, 1, 0 },
        { 1, 1, 1, 2, 2, 1, 1, 0 }, { 1, 1, 1, 2, 1, 1, 1, 1 },
        { 0, 1, 1, 2, 2, 2, 1, 0 }, { 0, 1, 1, 2, 2, 1, 1, 1 },
        { 1, 1, 2, 3, 2, 1, 0, 0 }, { 1, 1, 2, 2, 2, 1, 1, 0 },
        { 1, 1, 2, 2, 1, 1, 1, 1 }, { 1, 1, 1, 2, 2, 2, 1, 0 },
        { 1, 1, 1, 2, 2, 1, 1, 1 }, { 0, 1, 1, 2, 2, 2, 1, 1 },
        { 1, 2, 2, 3, 2, 1, 0, 0 }, { 1, 1, 2, 3, 2, 1, 1, 0 },
        { 1, 1, 2, 2, 2, 2, 1, 0 }, { 1, 1, 2, 2, 2, 1, 1, 1 },
        { 1, 1, 1, 2, 2, 2, 1, 1 }, { 0, 1, 1, 2, 2, 2, 2, 1 },
        { 1, 2, 2, 3, 2, 1, 1, 0 }, { 1, 1, 2, 3, 2, 2, 1, 0 },
        { 1, 1, 2, 3, 2, 1, 1, 1 }, { 1, 1, 2, 2, 2, 2, 1, 1 },
        { 1, 1, 1, 2, 2, 2, 2, 1 }, { 1, 2, 2, 3, 2, 2, 1, 0 },
        { 1, 2, 2, 3, 2, 1, 1, 1 }, { 1, 1, 2, 3, 3, 2, 1, 0 },
        { 1, 1, 2, 3, 2, 2, 1, 1 }, { 1, 1, 2, 2, 2, 2, 2, 1 },
        { 1, 2, 2, 3, 3, 2, 1, 0 }, { 1, 2, 2, 3, 2, 2, 1, 1 },
        { 1, 1, 2, 3, 3, 2, 1, 1 }, { 1, 1, 2, 3, 2, 2, 2, 1 },
        { 1, 2, 2, 4, 3, 2, 1, 0 }, { 1, 2, 2, 3, 3, 2, 1, 1 },
        { 1, 2, 2, 3, 2, 2, 2, 1 }, { 1, 1, 2, 3, 3, 2, 2, 1 },
        { 1, 2, 3, 4, 3, 2, 1, 0 }, { 1, 2, 2, 4, 3, 2, 1, 1 },
        { 1, 2, 2, 3, 3, 2, 2, 1 }, { 1, 1, 2, 3, 3, 3, 2, 1 },
        { 2, 2, 3, 4, 3, 2, 1, 0 }, { 1, 2, 3, 4, 3, 2, 1, 1 },
        { 1, 2, 2, 4, 3, 2, 2, 1 }, { 1, 2, 2, 3, 3, 3, 2, 1 },
        { 2, 2, 3, 4, 3, 2, 1, 1 }, { 1, 2, 3, 4, 3, 2, 2, 1 },
        { 1, 2, 2, 4, 3, 3, 2, 1 }, { 2, 2, 3, 4, 3, 2, 2, 1 },
        { 1, 2, 3, 4, 3, 3, 2, 1 }, { 1, 2, 2, 4, 4, 3, 2, 1 },
        { 2, 2, 3, 4, 3, 3, 2, 1 }, { 1, 2, 3, 4, 4, 3, 2, 1 },
        { 2, 2, 3, 4, 4, 3, 2, 1 }, { 1, 2, 3, 5, 4, 3, 2, 1 },
        { 2, 2, 3, 5, 4, 3, 2, 1 }, { 1, 3, 3, 5, 4, 3, 2, 1 },
        { 2, 3, 3, 5, 4, 3, 2, 1 }, { 2, 2, 4, 5, 4, 3, 2, 1 },
        { 2, 3, 4, 5, 4, 3, 2, 1 }, { 2, 3, 4, 6, 4, 3, 2, 1 },
        { 2, 3, 4, 6, 5, 3, 2, 1 }, { 2, 3, 4, 6, 5, 4, 2, 1 },
        { 2, 3, 4, 6, 5, 4, 3, 1 }, { 2, 3, 4, 6, 5, 4, 3, 2 } };
    private final static int[][] F4roots = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 },
	{ 0, 0, 1, 0 }, { 0, 0, 0, 1 }, { 1, 1, 0, 0 }, { 0, 1, 1, 0 },
	{ 0, 0, 1, 1 }, { 1, 1, 1, 0 }, { 0, 1, 1, 1 }, { 0, 1, 2, 0 },
	{ 0, 1, 2, 1 }, { 1, 1, 1, 1 }, { 1, 1, 2, 0 }, { 0, 1, 2, 2 },
	{ 1, 1, 2, 1 }, { 1, 2, 2, 0 }, { 1, 1, 2, 2 }, { 1, 2, 2, 1 },
	{ 1, 2, 2, 2 }, { 1, 2, 3, 1 }, { 1, 2, 3, 2 }, { 1, 2, 4, 2 },
	{ 1, 3, 4, 2 }, { 2, 3, 4, 2 } };
    private static final int[][] G2roots = { { 0, 1 }, { 1, 0 }, { 1, 1 },
	{ 1, 2 }, { 1, 3 }, { 2, 3 } };/*@\label{rootsend}@*/
    private final static int[] f4Byte = { 
	1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 1,
        0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, 0,
        1, -1, -2, 0, -2, -1, 0, 0, -1, 0, 0, 0, 0, 0, -1, -1, 0, -2, 0, 0,
        0, 0, -1, 0, -1, 0, -1, -2, 0, -1, 0, -2, -1, 0, -2, 0, -1, 0, 0,
        0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1,
        2, 0, 0, 0, 1, 0, 0, -1, 0, -1, 0, 0, 0, 2, 0, 0, 0, -1, -2, 0, 0,
        -2, 0, 0, 0, 1, 0, 1, 0, 2, 0, 0, 0, 0, -1, 0, 1, 0, 0, 1, 0, 0, 0,
        0, 0, 0, -2, 0, 0, 0, 0, 0, 2, 1, 0, 1, 0, 0, 0, 0, -2, 0, 0, 0, 0,
        0, 1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0,
        1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0,
        0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    private final static int[][] f4Cartan = { { 2, -1, 0, 0 },
    { -1, 2, -2, 0 }, { 0, -1, 2, -1 }, { 0, 0, -1, 2 } };
    private final static int[] F4NormSquares = { 2, 2, 1, 1, 2, 1, 1, 1, 1, 2,
    1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 2 };
    
    private final static int[][] f4WIIP = { { 4, -2, 0, 0 }, { -2, 4, -2, 0 },
    { 0, -2, 2, -1 }, { 0, 0, -1, 2 } };
    private final static int[] g2Byte = { -1, -2, 3, 0, 0, 0, 0, 1, 0, 3, 0, 0,
    0, 0, 0 };//these match jiang rallis
    private final static int[][] g2Cartan = { { 2, -1 }, { -3, 2 } };
    private final static int[] G2NormSquares = { 1, 3, 1, 1, 3, 3 };
    
    private static final int[][] G2WeylSigns = {
	{1,1},
	{1,1},
	{1,-1},
	{-1,-1},
	{-1,1},
	{-1,-1}
    };
	
    private static final int [][] G2WeylRoots = {
	{2,6},
	{7,4},
	{0,3},
	{3,2},
	{5,1},
	{4,5}
    };
    private final static int[][] g2WIIP = { { 2, -3 }, { -3, 6 } };
    
  
    private final static int[][] e8Cartan = { { 2, 0, -1, 0, 0, 0, 0, 0 },
	    { 0, 2, 0, -1, 0, 0, 0, 0 }, { -1, 0, 2, -1, 0, 0, 0, 0 },
	    { 0, -1, -1, 2, -1, 0, 0, 0 }, { 0, 0, 0, -1, 2, -1, 0, 0 },
	    { 0, 0, 0, 0, -1, 2, -1, 0 }, { 0, 0, 0, 0, 0, -1, 2, -1 },
	    { 0, 0, 0, 0, 0, 0, -1, 2 } };
    
    protected static int[][] positiveRoots( int rank ){
	if(rank == 2)
	    return G2roots;
	if( rank == 4)
	    return F4roots;
	if( rank == 6)
	    return E6roots;
	if( rank == 7)
	    return E7roots;
	if( rank == 8 )
	    return E8roots;
	else
	    return null;
	
	
    }
    
    
    protected static int[][] cartan( int rank )
    {
	
	
	   
	if (rank >= 6) {
	    int[][] ourCartan = new int[rank][rank];
	    // we exploit the fact that the Cartan matrices of E6 and E7 are
	    // submatrices of that of E8
	    for (int i = 0; i < rank; i++)
		for (int j = 0; j < rank; j++)
		    ourCartan[i][j] = e8Cartan[i][j]; // 
	    return ourCartan;

	} else if (rank == 4) {
	    return   f4Cartan;

	} else if (rank == 2) {
	    return g2Cartan;
	} else
	    throw new RuntimeException();// This should only be used on the
	// five
	// Exceptional groups
    }
    protected static int[][] weylInvtInnProd( int rank){
	   
	if (rank >= 6) {
	    return cartan( rank);	    // For simply laced groups the
	    //normalized Weyl invariant inner
	    // product is
	    // given by the Cartan matrix.

	} else if (rank == 4) {
	    return f4WIIP;

	} else if (rank == 2) {
	    return g2WIIP;
	} else
	    throw new RuntimeException();// This should only be used on the
	// five
	// Exceptional groups
    }
    /**
     * The matrix of structure constants for the unique exceptional Lie 
     * algebra of the specified rank
     * @param rank must equal 2, 4, 6, 7 or 8 
     * @return matrix of structure constants, either from a data file,
     *  or by implementing the algorithm 
     * described in a note of Gilkey and Seitz titled
     * Some representations of exceptional Lie algebras.
     */
   public static StructureConstantsMatrix scm( int rank)
   {
	   
	if (rank >= 6) {
	    return gilkeySeitz( new VectorCayleyTable( positiveRoots(rank)),
		    rank);

	} else if (rank == 4) {
	    return new StructureConstantsMatrix(F4roots, f4Byte, 24);

	} else if (rank == 2) {
	    return new StructureConstantsMatrix(G2roots, g2Byte, 6);
	} else
	    throw new RuntimeException();// This should only be used on the
	// five
	// Exceptional groups

   }
   

protected static int[] normSquares( int rank ){
       if( rank == 2)
	   return G2NormSquares;
       if( rank == 4)
	   return F4NormSquares;
       
   int[] answer = new int[positiveRoots(rank).length];

   Arrays.fill(answer, 1);
   return answer;
   }
   
   /**
    * Method for generating the matrix of structure constants for the
    * exceptional groups E6, E7, and E8.
    * 
    * @param additionTable
    *            the Cayley table for the positive roots of a root system
    * @param rank
    *            the rank of the exceptional group (valid choices are 6, 7, and
    *            8)
    * @return the matrix containing the structure constants
    */
   private static StructureConstantsMatrix gilkeySeitz(/*@\label{gilkeySeitz}@*/
	   VectorCayleyTable additionTable,
	   final int rank) {
	StructureConstantsMatrix matrix = new StructureConstantsMatrix(
		positiveRoots(rank),
		additionTable.length);
	Set<int[]> found = new HashSet<int[]>();
	int[][] z = additionTable.getRoots();

	// Phase I: a_i+b
	for (int i = 0; i < rank; i++) {
	    for (int j = i + 1; j < additionTable.length; j++) {
		int[] sum = additionTable.add(z[i], z[j]);
		if (sum != null && !found.contains(sum)) {
		    found.add(sum);
		    matrix.set(i, j, 1);
		}
	    }
	}

	// Phase II: a+b
	for (int i = 0; i < additionTable.length - 1; i++) {
	    for (int j = i + 1; j < additionTable.length; j++) {
		int[] sum = additionTable.add(z[i], z[j]);
		if (sum != null && matrix.get(z[i], z[j]) == 0) {
		    int min = minI(additionTable, rank, sum);
		    int[] k = additionTable.subtract(z[i], z[min]);
		    if (k != null) {
			matrix.set(
				i,
				j,
				(matrix.get(z[min], k) * matrix.get(k, z[j])));
		    } else {
			k = additionTable.subtract(z[j], z[min]);
			matrix.set(
				i, 
				j, 
				(-1 * matrix.get(z[min], k) 
					* matrix.get(k, z[i])));
		    }
		}
	    }
	}
	return matrix;
   }/*@\label{gilkeySeitzend}@*/

 

/**
 * Used in the Gilkey-Seitz algorithm for determining structure constants 
 * implemented in gilkeySeitz
 * 
 */
private static int minI(VectorCayleyTable roots, final int rank, int[] root) {/*@\label{minI}@*/
	int[][] z = roots.getRoots();
	for (int i = 0; i < rank - 1; i++) {
	    for (int j = i + 1; j < roots.length; j++) {
		if (Arrays.equals(roots.add(z[i], z[j]), root))
		    return i;
	    }
	}
	return (rank - 1);
}/*@\label{minIend}@*/


/**
 * Return where each positive root is sent after applying each simple refection.
 * @param rank the rank of the exceptional group to check
 * 
 * 
 * @return the list of root indices
 */
public static int [][] getWeylRoots(int rank) {
    if (rank ==2)
    return G2WeylRoots;
    throw new RuntimeException("only G2 supported now!");
}


/**
 * Returns the effect on the polynomial of a one parameter subgroup with
 * each associated root under each simple reflection.
 * @param rank the rank of the exceptional group to check
 * 
 * @return the list of signs
 */
public static int[][] getWeylSigns(int rank) {
    if (rank ==2)
    return G2WeylSigns;
    throw new RuntimeException("only G2 supported now!");
}



}
